package demo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//Day07
public class Day16003 {
    public static void main(String[] args) {
        Collection<String> collection=new ArrayList<>();
        collection.add("JavaEE企业级开发指南");
        collection.add("Oracle高级编程");
        collection.add("MySQL从入门到精通");
        collection.add("Java架构师之路");
//        全部打印
        all(collection);
//        筛选长度小于10的打印
        ten(collection);
//        筛选书名中带有java的打印
        haveJava(collection);
//        删除后遍历
        removeOracle(collection);
        Iterator<String> iterator=collection.iterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
    }
    public static void all(Collection<String> collection){
        Iterator<String> iterator=collection.iterator();
        System.out.println("全部打印：");
        while (iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
    }
    public static void ten(Collection<String> collection){
        Iterator<String> iterator=collection.iterator();
        System.out.println("\n筛选书名长度小于10个字符：");
        while (iterator.hasNext()){
            String s=iterator.next();
            if(s.length()<10){
                System.out.print(s+" ");
            }
        }
    }
    public static void haveJava(Collection<String> collection){
        Iterator<String> iterator=collection.iterator();
        System.out.println("\n筛选书名中带有java的：");
        while (iterator.hasNext()){
            String s=iterator.next();
            if (s.indexOf("Java")!=-1)
                System.out.print(s+" ");
        }
    }
    public static void removeOracle(Collection<String> collection){
        Iterator<String> iterator=collection.iterator();
        System.out.println("\n删除带有Oracle的：");
        while (iterator.hasNext()){
            String s=iterator.next();
            if (s.indexOf("Oracle")!=-1){
                iterator.remove();
            }
        }

    }
}
